import requests as rq
import sys

open_id = ""

if len(sys.argv) > 1:
    open_id = sys.argv[1]
else:
    try:
        with open('./id.txt', 'r') as f:
            open_id = f.read()
    except:
        with open('./id.txt', 'w') as f:
            print('输入你微信的openid:')
            open_id = input()
            f.write(open_id)

get_latest = '''http://qndxx.youth54.cn/SmartLA/dxxjfgl.w?method=getNewestVersionInfo'''
latest_info = rq.post(get_latest).json()
version = latest_info['version']
print(latest_info)

target = '''http://qndxx.youth54.cn/SmartLA/dxxjfgl.w'''
data = {
    'method': 'studyLatest',
    'version': version,
    'openid': open_id,
}
print(rq.post(target, data=data).json())
print("Done!")

